package com.shurdroides.proyectofinal.utils;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;


import com.shurdroides.proyectofinal.R;
import com.shurdroides.proyectofinal.activities.MapaActivity;
import com.shurdroides.proyectofinal.constants.Constants;

public class Utils implements Constants{

	
	public static final void createNotificationMessage(Context ctx, String s) {
		NotificationManager notificationManager = (NotificationManager) ctx
				.getSystemService(Context.NOTIFICATION_SERVICE);

		Notification notification = createNotification();
		Intent notificationIntent = new Intent(ctx, MapaActivity.class);
		notificationIntent.putExtra("mensaje", s);
		PendingIntent pendingIntent = PendingIntent.getActivity(ctx, 0,notificationIntent, 0);
		notification.setLatestEventInfo(ctx, "EVOLUTION",s, pendingIntent);
		notificationManager.notify(1000, notification);

	}

	private static Notification createNotification() {
		Notification notification = new Notification();
		notification.icon = R.drawable.elemento;
		notification.when = System.currentTimeMillis();
		notification.flags |= Notification.FLAG_AUTO_CANCEL;
		notification.flags |= Notification.FLAG_SHOW_LIGHTS;
		notification.defaults |= Notification.DEFAULT_VIBRATE;
		notification.defaults |= Notification.DEFAULT_LIGHTS;
		notification.audioStreamType = Notification.DEFAULT_SOUND;
		notification.ledARGB = Color.WHITE;
		notification.ledOnMS = 1500;
		notification.ledOffMS = 1500;

		return notification;
	}
	
	
	public static String quitarEspacios(String s){
		return s.replace(" ", "_");
	}
	
	public static String ponerEspacios(String s){
		return s.replace("_", " ");
	}
	
	
	public static String getMail(String s){
		String[] cad =s.split(" dice: ");
		return cad[0];
	}
	
}
